-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(hurl): fold not work if set foldexpr to vim.treesitter.foldexpr()
#162
Conversation
set filetype to `hurl-nvim` by default make `vim.treesitter.foldexpr()` not work, causes zc zo to fail. this commit check if edgy.nvim exists and then set filetype to hurl-nvim, otherwise just set filetype to input param type.
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
|
Your free trial has expired. To keep using Ellipsis, sign up at https://app.ellipsis.dev for $20/seat/month or reach us at [email protected] |
WalkthroughThe recent changes in the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Sweep: PR ReviewAuthors of pull request: @wenjinnn lua/hurl/split.luaMade the setting of the 'filetype' buffer option conditional based on the availability of 'edgy.nvim' and adjusted the timing of setting the filetype to the provided type parameter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- lua/hurl/split.lua (3 hunks)
Additional comments not posted (1)
lua/hurl/split.lua (1)
23-23
: Safe use ofpcall
to check foredgy.nvim
.Using
pcall
here is a good practice as it prevents the application from crashing ifedgy.nvim
is not present or fails to load. This is a robust way to handle optional dependencies.
if pcall(require, 'edgy') then | ||
-- Create a custom filetype so that we can use https://github.com/folke/edgy.nvim to manage the window | ||
-- E.g: { title = "Hurl Nvim", ft = "hurl-nvim" }, | ||
vim.api.nvim_buf_set_option(split.bufnr, 'filetype', 'hurl-nvim') | ||
end | ||
|
||
-- Set content to highlight, refer https://github.com/MunifTanjim/nui.nvim/issues/76#issuecomment-1001358770 | ||
vim.api.nvim_buf_set_option(split.bufnr, 'filetype', type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential issue: The filetype is set twice when edgy.nvim
is available.
The current logic sets the filetype to 'hurl-nvim' if edgy.nvim
is available (line 26), but then it immediately sets it again to the type
parameter (line 30). This could lead to unexpected behavior or override settings intended for 'hurl-nvim'. Consider restructuring the logic to ensure the filetype is set only once based on the conditions.
Hi @wenjinnn
That's exactly what the author answered as below. The usage is correct. buf_options = { filetype = 'hurl-nvim' }, |
Thanks for reply @jellydn . I think this issue you refers to just explain this PR. set filetype to
Although we got treesitter highlight, but we can't get foldlevel calculate by
And this is another problem I want to improve yet, just discuss in here. right now the response buffer have no name, it shows like: |
That sounds good @wenjinnn Let's do it. Thanks. |
Thanks @wenjinnn LGTM! |
One thing I noticed on this PR @wenjinnn the
|
After we have buffer name, this setting could work with edgy.nvim, just a little wordy:
I can update the README, and maybe remove all these lines at Lines 22 to 27 in a185094
|
Well, that won't work as well. The |
FYI - Fixed with my commit, here is the working config https://github.com/jellydn/lazy-nvim-ide/blob/main/lua/plugins/extras/hurl.lua |
Oh sorry for that, I just try it once with edgy.nvim, cuz I don't really use it daily.
|
This made fold level computing failed again. but I find a way to compatible with edgy.nvim and the treesitter foldexpr, I'll open another PR. |
Set filetype to
hurl-nvim
by default makevim.treesitter.foldexpr()
not work, causes zc zo to fail in response buffer, it happens only on nvim 0.10. this commit check if edgy.nvim exists and then set filetype to hurl-nvim, otherwise just set filetype to input paramtype
.Also I was wondering if there have any way to set buf name safety with nui.nvim?
I tried to use
vim.api.nvim_buf_set_name(split.bufnr, 'hurl-response')
at split.show, but got a error when run a request second time, it seems like bufnr got wrong value or something. I would love to make a PR if I can fix it, right now the split result window have no name, maybe add a name will be nice.Summary by CodeRabbit
edgy.nvim
when available.